// pages/home/product/preproduct/preproductIndex/preproductIndex.js
const globalIp = getApp().globalData.userIp
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    info: '',
    CardCode: '',
    type: ''
  },

  getInputValue(e) {
    this.setData({
      info: e.detail.value
    })
  },

  selectData: function(){
    this.allShow();
  },

  allShow: function(options){
    var that = this;
    wx.showLoading({
      title: '数据加载中...',
    })
    wx.request({
      url: globalIp + 'home/oitm/preProduct',
      data: {
        cardCode: (options && options.CardCode) || that.data.CardCode,
        status: (options && options.type) || that.data.type,
        value: 3,
        openId: wx.getStorageSync('userInfo').openid,
        pageIndex: 0,
        pageSize: 0,
        userName: that.data.info
      },
      header: {
        'content-type': 'application/json'
      },
      method: 'POST',
      success: function(res) {
        that.setData({
          list: res.data.jsonObject.data
        })
      },
      complete: () => {
        wx.hideLoading()
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      CardCode: options.CardCode,
      type: options.type
    })
    this.allShow(options)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },
})